<template>
  <div class="home">
    <el-container>
      <el-header height="80px">
        <div>
          <img src="https://www.escook.cn/vue-shop/img/heima.b5a855ee.png" alt />
          <p>电商后台管理系统</p>
        </div>
        <el-button type="success" @click="retu">返回登录页面</el-button>
      </el-header>
      <el-container>
        <el-aside :width="falg?'64px':'200px'">
          <p @click="falg=!falg">|||</p>
          <el-menu
            default-active="1"
            class="el-menu-vertical-demo"
            background-color="#545c64"
            text-color="#fff"
          
            :collapse="falg"
            :unique-opened="true"
            :collapse-transition="false"
            router
          >
            <el-submenu :index="item.id+''" v-for="item in menulist" :key="item.id">
              <template slot="title">
                <i :class="iconname[item.id]"></i>
                <span>{{item.authName}}</span>
              </template>

              <el-menu-item :index="it.path" v-for="it in item.children" :key="it.id" @click="getPath(item.authName,it.authName)">
                <i class="el-icon-star-on"></i>
                <span>{{it.authName}}</span>
              </el-menu-item>
            </el-submenu>
          </el-menu>
        </el-aside>
        <el-main>
          <router-view></router-view>
        </el-main>
      </el-container>
    </el-container>
  </div>
</template>
<script>
export default {
  data() {
    return {
      menulist: [],
      falg: false,
      iconname: {
        "125": "el-icon-user-solid",
        "103": "el-icon-loading",
        "101": "el-icon-magic-stick",
        "102": "el-icon-suitcase",
        "145": "el-icon-bangzhu"
      }
    };
  },
  mounted() {
    this.getMenu();
  },
  methods: {
    retu() {
      //退出,清除sessionstrong中的信息
      sessionStorage.clear();
      this.$router.push("/login");
    },
    async getMenu() {
      var res = await this.$http.get("/menus");
      console.log(res.data.data);
      this.menulist = res.data.data;
    },
    //跳转菜单页面包屑导航
    getPath(onename,twoname){
      var obj = {'one':onename,'two':twoname};
      // console.log(one,two)
      sessionStorage.setItem("path",JSON.stringify(obj))
    }
  }
};
</script>
<style lang="scss" scoped>
.home {
  width: 100%;
  height: 100%;
  display: flex;
  flex-direction: column;
  .el-container {
    width: 100%;
    height: 100%;
    .el-header {
      display: flex;
      justify-content: space-between;
      align-items: center;
      background: #373d41;
      width: 100%;
      height: 100px;
      div {
        display: flex;
        align-items: center;
        img {
          width: 70px;
          height: 70px;
        }
        p {
          margin-left: 20px;
          font-size: 24px;
          color: white;
          font-weight: 700;
        }
      }
    }
    .el-container {
      display: flex;
      flex: 1;
      justify-content: space-between;
      .el-aside {
        width: 200px;
        background-color: #333744;
        p {
          background: #333744;
          text-align: center;
          color: white;
          font-size: 14px;
          padding: 4px 0;
          letter-spacing: 2px;
        }
      }
      .el-main {
        flex: 1;
        background-color: #eaedf1;
      }
    }
  }
}
</style>